
class BaseHasVDtor {
public:
    virtual ~BaseHasVDtor() {}

    virtual void foo() const = 0;
};

class BaseNoVDtor {
public:
    ~BaseNoVDtor() {}
    virtual void foo() const = 0;
};

class Derived1 : public BaseHasVDtor {
    mutable int mydata[10];
public:
    void foo() const override {
        for (auto &x: mydata)
            x += 10;
    }
    void bar() const {
        for (auto &x: mydata)
            x += 10;
    }
};

class Derived2 : public BaseNoVDtor {
    mutable int mydata[10];
public:
    void foo() const override {
        for (auto &x: mydata)
            x += 10;
    }
    void bar() const {
        for (auto &x: mydata)
            x += 10;
    }
};

template<typename I>
static void release(I *i) {
    i->foo();
    delete i;
}

int main() {
    Derived2 *x = new Derived2;
    release<BaseNoVDtor>(x);
    x->bar();
    Derived1 *y = new Derived1;
    release<BaseHasVDtor>(y);
    y->bar();
}